package com.yanqu.road.server.manger.activity.entername.impl;

import com.yanqu.road.entity.activity.entername.ActivityGroupMatch;
import com.yanqu.road.pb.cross3.activity.EnterNameProto;
import com.yanqu.road.server.manger.activity.entername.EnterNameActivityConfig;
import com.yanqu.road.server.manger.activity.entername.EnterNameActivityMgr;
import com.yanqu.road.server.manger.activity.entername.EnterNameCache;

import java.util.List;

public abstract class AbstractEnterNameChangeListener {

    public abstract void notifyGrouping(EnterNameProto.UserEnterNameMsg nameMsg,  List<ActivityGroupMatch> list, EnterNameActivityConfig config);

    public abstract void notifyName(long userId, int activityId , EnterNameCache cache);

    public abstract boolean supportType(int activityType);

    public void notifyGrouping(int activityId, EnterNameProto.UserEnterNameMsg nameMsg, List<ActivityGroupMatch> list){
        EnterNameActivityConfig config = EnterNameActivityMgr.getActivityConfig(activityId);
        if(config != null && supportType(config.getActivityInfo().getType())){
            notifyGrouping(nameMsg, list, config);
        }
    }

    public void notifyName(long userId, int activityId){
        EnterNameCache cache = EnterNameActivityMgr.getEnterNameCache(activityId, userId);
        if(cache != null){
            notifyName(userId, activityId, cache);
        }
    }

    public void notifyName(int activityId, List<Long> playerList){
        EnterNameActivityConfig config = EnterNameActivityMgr.getActivityConfig(activityId);
        if(config != null && supportType(config.getActivityInfo().getType())){
            for (long userId : playerList) {
                notifyName(userId, activityId);
            }
        }
    }
}
